<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>TeamSpeak 3 PHP Framework: API Documentation</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="TeamSpeak.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">TeamSpeak 3 PHP Framework
   &#160;<span id="projectnumber">1.1.23</span>
   </div>
   <div id="projectbrief">Copyright © Planet TeamSpeak. All rights reserved.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li class="current"><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('index.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">API Documentation </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="welcome_sec"></a>
Introduction</h1>
<h2><a class="anchor" id="welcome1"></a>
What is the TS3 PHP Framework?</h2>
<p>Initially released in January 2010, the TS3 PHP Framework is a powerful, open source, object-oriented framework implemented in PHP 5 and licensed under the GNU General Public License. It's based on simplicity and a rigorously tested agile codebase. Extend the functionality of your servers with scripts or create powerful web applications to manage all features of your TeamSpeak 3 Server instances.</p>
<p>Tested. Thoroughly. Enterprise-ready and built with agile methods, the TS3 PHP Framework has been unit-tested from the start to ensure that all code remains stable and easy for you to extend, re-test with your extensions, and further maintain.</p>
<h2><a class="anchor" id="welcome2"></a>
Why should I use the TS3 PHP Framework rather than other PHP libraries?</h2>
<p>The TS3 PHP Framework is a is a modern use-at-will framework that provides individual components to communicate with the TeamSpeak 3 Server.</p>
<p>There are lots of arguments for the TS3 PHP Framework in comparison with other PHP based libraries. It is the most dynamic and feature-rich piece of software in its class. In addition, it's always up-to-date and 100% compatible to almost any TeamSpeak 3 Server version available.</p>
<h1><a class="anchor" id="sysreqs_sec"></a>
Requirements</h1>
<p>The TS3 PHP Framework currently supports PHP 5.2.1 or later, but we strongly recommend the most current release of PHP for critical security and performance enhancements. If you want to create a web application using the TS3 PHP Framework, you need a PHP 5 interpreter with a web server configured to handle PHP scripts correctly.</p>
<p>Note that the majority of TS3 PHP Framework development and deployment is done on nginx, so there is more community experience and testing performed on nginx than on other web servers.</p>
<h1><a class="anchor" id="feature_sec"></a>
Features</h1>
<p>Features of the TS3 PHP Framework include:</p>
<ul>
<li>Fully object-oriented PHP 5 and E_STRICT compliant components</li>
<li>Access to all TeamSpeak 3 Server features via ServerQuery</li>
<li>Integrated full featured and customizable TSViewer interfaces</li>
<li>Full support for file transfers to up- and /or download custom icons and other stuff</li>
<li>Powerful error handling capablities using exceptions and customizable error messages</li>
<li>Query mechanisms for several official services such as the blacklist and auto-update servers</li>
<li>Dynamic signal slots for event based scripting</li>
<li>...</li>
</ul>
<h1><a class="anchor" id="example_sec"></a>
Usage Examples</h1>
<h2><a class="anchor" id="example1"></a>
1. Kick a single Client from a Virtual Server</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// kick the client with ID 123 from the server</span></div>
<div class="line">$ts3_VirtualServer-&gt;clientKick(123, <a class="code" href="class_team_speak3.html#ae9df1f0980b1d3e9638b3a8084cc5234" title="5: kick client from server ">TeamSpeak3::KICK_SERVER</a>, <span class="stringliteral">&quot;evil kick XD&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// spawn an object for the client by unique identifier and do the kick</span></div>
<div class="line">$ts3_VirtualServer-&gt;clientGetByUid(<span class="stringliteral">&quot;FPMPSC6MXqXq751dX7BKV0JniSo=&quot;</span>)-&gt;kick(<a class="code" href="class_team_speak3.html#ae9df1f0980b1d3e9638b3a8084cc5234" title="5: kick client from server ">TeamSpeak3::KICK_SERVER</a>, <span class="stringliteral">&quot;evil kick XD&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// spawn an object for the client by current nickname and do the kick</span></div>
<div class="line">$ts3_VirtualServer-&gt;clientGetByName(<span class="stringliteral">&quot;ScP&quot;</span>)-&gt;kick(<a class="code" href="class_team_speak3.html#ae9df1f0980b1d3e9638b3a8084cc5234" title="5: kick client from server ">TeamSpeak3::KICK_SERVER</a>, <span class="stringliteral">&quot;evil kick XD&quot;</span>);</div>
</div><!-- fragment --><h2><a class="anchor" id="example2"></a>
2. Kick all Clients from a Virtual Server</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// query clientlist from virtual server</span></div>
<div class="line">$arr_ClientList = $ts3_VirtualServer-&gt;clientList();</div>
<div class="line"></div>
<div class="line"><span class="comment">// kick all clients online with a single command</span></div>
<div class="line">$ts3_VirtualServer-&gt;clientKick($arr_ClientList, <a class="code" href="class_team_speak3.html#ae9df1f0980b1d3e9638b3a8084cc5234" title="5: kick client from server ">TeamSpeak3::KICK_SERVER</a>, <span class="stringliteral">&quot;evil kick XD&quot;</span>);</div>
</div><!-- fragment --><h2><a class="anchor" id="example3"></a>
3. Print the Nicknames of connected Android Clients</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// query clientlist from virtual server and filter by platform</span></div>
<div class="line">$arr_ClientList = $ts3_VirtualServer-&gt;clientList(array(<span class="stringliteral">&quot;client_platform&quot;</span> =&gt; <span class="stringliteral">&quot;Android&quot;</span>));</div>
<div class="line"></div>
<div class="line"><span class="comment">// walk through list of clients</span></div>
<div class="line"><span class="keywordflow">foreach</span>($arr_ClientList as $ts3_Client)</div>
<div class="line">{</div>
<div class="line">  echo $ts3_Client . <span class="stringliteral">&quot; is using &quot;</span> . $ts3_Client[<span class="stringliteral">&quot;client_platform&quot;</span>] . <span class="stringliteral">&quot;&lt;br /&gt;\n&quot;</span>;</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="example4"></a>
4. Modify the Settings of each Virtual Server</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the server instance</span></div>
<div class="line">$ts3_ServerInstance = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// walk through list of virtual servers</span></div>
<div class="line"><span class="keywordflow">foreach</span>($ts3_ServerInstance as $ts3_VirtualServer)</div>
<div class="line">{</div>
<div class="line">  <span class="comment">// modify the virtual servers hostbanner URL only using the ArrayAccess interface</span></div>
<div class="line">  $ts3_VirtualServer[<span class="stringliteral">&quot;virtualserver_hostbanner_gfx_url&quot;</span>] = <span class="stringliteral">&quot;http://www.example.com/banners/banner01_468x60.jpg&quot;</span>;</div>
<div class="line"></div>
<div class="line">  <span class="comment">// modify the virtual servers hostbanner URL only using property overloading</span></div>
<div class="line">  $ts3_VirtualServer-&gt;virtualserver_hostbanner_gfx_url = <span class="stringliteral">&quot;http://www.example.com/banners/banner01_468x60.jpg&quot;</span>;</div>
<div class="line"></div>
<div class="line">  <span class="comment">// modify multiple virtual server properties at once</span></div>
<div class="line">  $ts3_VirtualServer-&gt;modify(array(</div>
<div class="line">    <span class="stringliteral">&quot;virtualserver_hostbutton_tooltip&quot;</span> =&gt; <span class="stringliteral">&quot;My Company&quot;</span>,</div>
<div class="line">    <span class="stringliteral">&quot;virtualserver_hostbutton_url&quot;</span>     =&gt; <span class="stringliteral">&quot;http://www.example.com&quot;</span>,</div>
<div class="line">    <span class="stringliteral">&quot;virtualserver_hostbutton_gfx_url&quot;</span> =&gt; <span class="stringliteral">&quot;http://www.example.com/buttons/button01_24x24.jpg&quot;</span>,</div>
<div class="line">  ));</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="example5"></a>
5. Create a Privilege Key for a Server Group</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// spawn an object for the group using a specified name</span></div>
<div class="line">$arr_ServerGroup = $ts3_VirtualServer-&gt;serverGroupGetByName(<span class="stringliteral">&quot;Admins&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// create the privilege key</span></div>
<div class="line">$ts3_PrivilegeKey = $arr_ServerGroup-&gt;privilegeKeyCreate();</div>
</div><!-- fragment --><h2><a class="anchor" id="example6"></a>
6. Modify the Permissions of Admins on each Virtual Server</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the server instance</span></div>
<div class="line">$ts3_ServerInstance = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// walk through list of virtual servers</span></div>
<div class="line"><span class="keywordflow">foreach</span>($ts3_ServerInstance as $ts3_VirtualServer)</div>
<div class="line">{</div>
<div class="line">  <span class="comment">// identify the most powerful group on the virtual server</span></div>
<div class="line">  $ts3_ServerGroup = $ts3_VirtualServer-&gt;serverGroupIdentify();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// assign a new permission</span></div>
<div class="line">  $ts3_ServerGroup-&gt;permAssign(<span class="stringliteral">&quot;b_virtualserver_modify_hostbanner&quot;</span>, TRUE);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// revoke an existing permission</span></div>
<div class="line">  $ts3_ServerGroup-&gt;permRemove(<span class="stringliteral">&quot;b_virtualserver_modify_maxclients&quot;</span>);</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="example7"></a>
7. Create a new Virtual Server</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the server instance</span></div>
<div class="line">$ts3_ServerInstance = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// create a virtual server and get its ID</span></div>
<div class="line">$new_sid = $ts3_ServerInstance-&gt;serverCreate(array(</div>
<div class="line">  <span class="stringliteral">&quot;virtualserver_name&quot;</span>               =&gt; <span class="stringliteral">&quot;My TeamSpeak 3 Server&quot;</span>,</div>
<div class="line">  <span class="stringliteral">&quot;virtualserver_maxclients&quot;</span>         =&gt; 64,</div>
<div class="line">  <span class="stringliteral">&quot;virtualserver_hostbutton_tooltip&quot;</span> =&gt; <span class="stringliteral">&quot;My Company&quot;</span>,</div>
<div class="line">  <span class="stringliteral">&quot;virtualserver_hostbutton_url&quot;</span>     =&gt; <span class="stringliteral">&quot;http://www.example.com&quot;</span>,</div>
<div class="line">  <span class="stringliteral">&quot;virtualserver_hostbutton_gfx_url&quot;</span> =&gt; <span class="stringliteral">&quot;http://www.example.com/buttons/button01_24x24.jpg&quot;</span>,</div>
<div class="line">));</div>
</div><!-- fragment --><h2><a class="anchor" id="example8"></a>
8. Create a hierarchical Channel Stucture</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// create a top-level channel and get its ID</span></div>
<div class="line">$top_cid = $ts3_VirtualServer-&gt;channelCreate(array(</div>
<div class="line">  <span class="stringliteral">&quot;channel_name&quot;</span>           =&gt; <span class="stringliteral">&quot;My Channel&quot;</span>,</div>
<div class="line">  <span class="stringliteral">&quot;channel_topic&quot;</span>          =&gt; <span class="stringliteral">&quot;This is a top-level channel&quot;</span>,</div>
<div class="line">  <span class="stringliteral">&quot;channel_codec&quot;</span>          =&gt; <a class="code" href="class_team_speak3.html#a7e144effeaf513a660467a0dadd1ae97" title="1: speex wideband (mono, 16bit, 16kHz) ">TeamSpeak3::CODEC_SPEEX_WIDEBAND</a>,</div>
<div class="line">  <span class="stringliteral">&quot;channel_flag_permanent&quot;</span> =&gt; TRUE,</div>
<div class="line">));</div>
<div class="line"></div>
<div class="line"><span class="comment">// create a sub-level channel and get its ID</span></div>
<div class="line">$sub_cid = $ts3_VirtualServer-&gt;channelCreate(array(</div>
<div class="line">  <span class="stringliteral">&quot;channel_name&quot;</span>           =&gt; <span class="stringliteral">&quot;My Sub-Channel&quot;</span>,</div>
<div class="line">  <span class="stringliteral">&quot;channel_topic&quot;</span>          =&gt; <span class="stringliteral">&quot;This is a sub-level channel&quot;</span>,</div>
<div class="line">  <span class="stringliteral">&quot;channel_codec&quot;</span>          =&gt; <a class="code" href="class_team_speak3.html#a73cb8b928682f11db10d5f4bf92c579d" title="0: speex narrowband (mono, 16bit, 8kHz) ">TeamSpeak3::CODEC_SPEEX_NARROWBAND</a>,</div>
<div class="line">  <span class="stringliteral">&quot;channel_flag_permanent&quot;</span> =&gt; TRUE,</div>
<div class="line">  <span class="stringliteral">&quot;cpid&quot;</span>                   =&gt; $top_cid,</div>
<div class="line">));</div>
</div><!-- fragment --><h2><a class="anchor" id="example9"></a>
9. Send a Text Message to outdated Clients</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to default update server</span></div>
<div class="line">$ts3_UpdateServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;update&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// walk through list of clients on virtual server</span></div>
<div class="line"><span class="keywordflow">foreach</span>($ts3_VirtualServer-&gt;clientList() as $ts3_Client)</div>
<div class="line">{</div>
<div class="line">  <span class="comment">// skip query clients</span></div>
<div class="line">  <span class="keywordflow">if</span>($ts3_Client[<span class="stringliteral">&quot;client_type&quot;</span>]) <span class="keywordflow">continue</span>;</div>
<div class="line"></div>
<div class="line">  <span class="comment">// send test message if client build is outdated</span></div>
<div class="line">  <span class="keywordflow">if</span>($ts3_Client-&gt;getRev() &lt; $ts3_UpdateServer-&gt;getClientRev())</div>
<div class="line">  {</div>
<div class="line">    $ts3_Client-&gt;message(<span class="stringliteral">&quot;[COLOR=red]your client is [B]outdated[/B]... update to [U]&quot;</span> . $ts3_UpdateServer-&gt;getClientVersion() . <span class="stringliteral">&quot;[/U] now![/COLOR]&quot;</span>);</div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="example10"></a>
10. Check if the Server Instance is Outdated or Blacklisted</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the server instance</span></div>
<div class="line">$ts3_ServerInstance = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to default update server</span></div>
<div class="line">$ts3_UpdateServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;update&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// send global text message if the server is outdated</span></div>
<div class="line"><span class="keywordflow">if</span>($ts3_ServerInstance-&gt;version(<span class="stringliteral">&quot;build&quot;</span>) &lt; $ts3_UpdateServer-&gt;getServerRev())</div>
<div class="line">{</div>
<div class="line">  $ts3_ServerInstance-&gt;message(<span class="stringliteral">&quot;[COLOR=red]your server is [B]outdated[/B]... update to [U]&quot;</span> . $ts3_UpdateServer-&gt;getServerVersion() . <span class="stringliteral">&quot;[/U]  now![/COLOR]&quot;</span>);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to default blacklist server</span></div>
<div class="line">$ts3_BlacklistServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;blacklist&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// send global text message if the server is blacklisted</span></div>
<div class="line"><span class="keywordflow">if</span>($ts3_BlacklistServer-&gt;isBlacklisted($ts3_ServerInstance))</div>
<div class="line">{</div>
<div class="line">  $ts3_ServerInstance-&gt;message(<span class="stringliteral">&quot;[COLOR=red]your server is [B]blacklisted[/B]... disconnect now![/COLOR]&quot;</span>);</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="example11"></a>
11. Create a simple TSViewer for your Website</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// build and display HTML treeview using custom image paths (remote icons will be embedded using data URI sheme)</span></div>
<div class="line">echo $ts3_VirtualServer-&gt;getViewer(<span class="keyword">new</span> <a class="code" href="class_team_speak3___viewer___html.html" title="Renders nodes used in HTML-based TeamSpeak 3 viewers. ">TeamSpeak3_Viewer_Html</a>(<span class="stringliteral">&quot;images/viewericons/&quot;</span>, <span class="stringliteral">&quot;images/countryflags/&quot;</span>, <span class="stringliteral">&quot;data:image&quot;</span>));</div>
</div><!-- fragment --><h2><a class="anchor" id="example12"></a>
12. Update all outdated Audio Codecs to their Opus equivalent</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// walk through list of chanels</span></div>
<div class="line"><span class="keywordflow">foreach</span>($ts3_VirtualServer-&gt;channelList() as $ts3_Channel)</div>
<div class="line">{</div>
<div class="line">  <span class="keywordflow">if</span>($ts3_Channel[<span class="stringliteral">&quot;channel_codec&quot;</span>] == <a class="code" href="class_team_speak3.html#a8706d107a6d0bd56003436cf91931015" title="3: celt mono (mono, 16bit, 48kHz) ">TeamSpeak3::CODEC_CELT_MONO</a>)</div>
<div class="line">  {</div>
<div class="line">    $ts3_Channel[<span class="stringliteral">&quot;channel_codec&quot;</span>] = <a class="code" href="class_team_speak3.html#ad86387b6183780d2af6a1918552fc00b" title="3: opus music (interactive) ">TeamSpeak3::CODEC_OPUS_MUSIC</a>;</div>
<div class="line">  }</div>
<div class="line">  elseif($ts3_Channel[<span class="stringliteral">&quot;channel_codec&quot;</span>] != <a class="code" href="class_team_speak3.html#ad86387b6183780d2af6a1918552fc00b" title="3: opus music (interactive) ">TeamSpeak3::CODEC_OPUS_MUSIC</a>)</div>
<div class="line">  {</div>
<div class="line">    $ts3_Channel[<span class="stringliteral">&quot;channel_codec&quot;</span>] = <a class="code" href="class_team_speak3.html#ac8a12a60994f2949c63e21d8915c8afa" title="3: opus voice (interactive) ">TeamSpeak3::CODEC_OPUS_VOICE</a>;</div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="example13"></a>
13. Display the Avatar of a connected User</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// spawn an object for the client using a specified nickname</span></div>
<div class="line">$ts3_Client = $ts3_VirtualServer-&gt;clientGetByName(<span class="stringliteral">&quot;John Doe&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// download the clients avatar file</span></div>
<div class="line">$avatar = $ts3_Client-&gt;avatarDownload();</div>
<div class="line"></div>
<div class="line"><span class="comment">// send header and display image</span></div>
<div class="line">header(<span class="stringliteral">&quot;Content-Type: &quot;</span> . <a class="code" href="class_team_speak3___helper___convert.html#af9f1557a852d6c51fc71d8f5199594f4" title="Tries to detect the type of an image by a given string and returns it. ">TeamSpeak3_Helper_Convert::imageMimeType</a>($avatar));</div>
<div class="line">echo $avatar;</div>
</div><!-- fragment --><h2><a class="anchor" id="example14"></a>
14. Create a Simple Bot waiting for Events</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server in non-blocking mode, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&amp;blocking=0&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// get notified on incoming private messages</span></div>
<div class="line">$ts3_VirtualServer-&gt;notifyRegister(<span class="stringliteral">&quot;textprivate&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// register a callback for notifyTextmessage events </span></div>
<div class="line"><a class="code" href="class_team_speak3___helper___signal.html#af156036673730a599c10c8cbfd5e50bf" title="Returns a singleton instance of TeamSpeak3_Helper_Signal. ">TeamSpeak3_Helper_Signal::getInstance</a>()-&gt;subscribe(<span class="stringliteral">&quot;notifyTextmessage&quot;</span>, <span class="stringliteral">&quot;onTextmessage&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// wait for events</span></div>
<div class="line"><span class="keywordflow">while</span>(1) $ts3_VirtualServer-&gt;getAdapter()-&gt;wait();</div>
<div class="line"></div>
<div class="line"><span class="comment">// define a callback function</span></div>
<div class="line"><span class="keyword">function</span> onTextmessage(<a class="code" href="class_team_speak3___adapter___server_query___event.html" title="Provides methods to analyze and format a ServerQuery event. ">TeamSpeak3_Adapter_ServerQuery_Event</a> $event, <a class="code" href="class_team_speak3___node___host.html" title="Class describing a TeamSpeak 3 server instance and all it&#39;s parameters. ">TeamSpeak3_Node_Host</a> $host)</div>
<div class="line">{</div>
<div class="line">  echo <span class="stringliteral">&quot;Client &quot;</span> . $event[<span class="stringliteral">&quot;invokername&quot;</span>] . <span class="stringliteral">&quot; sent textmessage: &quot;</span> . $event[<span class="stringliteral">&quot;msg&quot;</span>];</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="example15"></a>
15. Handle Errors using Exceptions and Custom Error Messages</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// register custom error message (supported placeholders are: %file, %line, %code and %mesg)</span></div>
<div class="line"><a class="code" href="class_team_speak3___exception.html#a0b2ddaae2a81d54b3f730f7661039c7a" title="Registers a custom error message to $code. ">TeamSpeak3_Exception::registerCustomMessage</a>(0x300, <span class="stringliteral">&quot;The specified channel does not exist; server said: %mesg&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="keywordflow">try</span></div>
<div class="line">{</div>
<div class="line">  <span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">  $ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// spawn an object for the channel using a specified name</span></div>
<div class="line">  $ts3_Channel = $ts3_VirtualServer-&gt;channelGetByName(<span class="stringliteral">&quot;I do not exist&quot;</span>);</div>
<div class="line">}</div>
<div class="line"><span class="keywordflow">catch</span>(<a class="code" href="class_team_speak3___exception.html" title="Enhanced exception class for TeamSpeak3 objects. ">TeamSpeak3_Exception</a> $e)</div>
<div class="line">{</div>
<div class="line">  <span class="comment">// print the error message returned by the server</span></div>
<div class="line">  echo <span class="stringliteral">&quot;Error &quot;</span> . $e-&gt;getCode() . <span class="stringliteral">&quot;: &quot;</span> . $e-&gt;getMessage();</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="example16"></a>
16. Save Connection State in Persistent Session Variable</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// start a PHP session</span></div>
<div class="line">session_start();</div>
<div class="line"></div>
<div class="line"><span class="comment">// connect to local server, authenticate and spawn an object for the virtual server on port 9987</span></div>
<div class="line">$ts3_VirtualServer = <a class="code" href="class_team_speak3.html#aed403cdb559cae556a94a0d9823bcaf4" title="Factory for TeamSpeak3_Adapter_Abstract classes. ">TeamSpeak3::factory</a>(<span class="stringliteral">&quot;serverquery://username:password@127.0.0.1:10011/?server_port=9987&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// save connection state (including login and selected virtual server)</span></div>
<div class="line">$_SESSION[<span class="stringliteral">&quot;_TS3&quot;</span>] = serialize($ts3_VirtualServer);</div>
</div><!-- fragment --><h2><a class="anchor" id="example17"></a>
17. Restore Connection State from Persistent Session Variable</h2>
<div class="fragment"><div class="line"><span class="comment">// load framework files</span></div>
<div class="line">require_once(<span class="stringliteral">&quot;libraries/TeamSpeak3/TeamSpeak3.php&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// start a PHP session</span></div>
<div class="line">session_start();</div>
<div class="line"></div>
<div class="line"><span class="comment">// restore connection state</span></div>
<div class="line">$ts3_VirtualServer = unserialize($_SESSION[<span class="stringliteral">&quot;_TS3&quot;</span>]);</div>
<div class="line"></div>
<div class="line"><span class="comment">// send a text message to the server</span></div>
<div class="line">$ts3_VirtualServer-&gt;message(<span class="stringliteral">&quot;Hello World!&quot;</span>);</div>
</div><!-- fragment --><p>Speed up new development and reduce maintenance costs by using the TS3 PHP Framework! </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Fri Oct 11 2013 23:35:44 for TeamSpeak 3 PHP Framework by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.4 </li>
  </ul>
</div>
</body>
</html>
